using MediatR;
using S.O.ErrorCode;

namespace S.O.Api.Write.Application.Command.Medical
{
    /// <summary>
    /// 创建收费记录命令
    /// 用于门诊收费处理，包括药品费用结算和付费状态更新
    /// </summary>
    public class CreateChargeCommand : IRequest<APIResult<string>>
    {
        /// <summary>
        /// 患者ID
        /// </summary>
        public long PatientId { get; set; }
        
        /// <summary>
        /// 挂单号
        /// </summary>
        public string RegistrationNo { get; set; } = string.Empty;
        
        /// <summary>
        /// 总金额
        /// </summary>
        public decimal TotalAmount { get; set; }
        
        /// <summary>
        /// 实付金额
        /// </summary>
        public decimal PaidAmount { get; set; }
        
        /// <summary>
        /// 找零金额
        /// </summary>
        public decimal ChangeAmount { get; set; }
        
        /// <summary>
        /// 收费项目列表
        /// </summary>
        public List<ChargeItemDto> ChargeItems { get; set; } = new List<ChargeItemDto>();
        
        /// <summary>
        /// 收费时间
        /// </summary>
        public DateTime ChargeTime { get; set; } = DateTime.Now;
        
        /// <summary>
        /// 收费员
        /// </summary>
        public string Cashier { get; set; } = string.Empty;
        
        /// <summary>
        /// 支付方式（现金、刷卡、微信、支付宝等）
        /// </summary>
        public string PaymentMethod { get; set; } = "现金";
        
        /// <summary>
        /// 备注信息
        /// </summary>
        public string? Remarks { get; set; }
    }
    
    /// <summary>
    /// 收费项目DTO
    /// </summary>
    public class ChargeItemDto
    {
        /// <summary>
        /// 药品ID
        /// </summary>
        public string MedicineId { get; set; } = string.Empty;
        
        /// <summary>
        /// 药品名称
        /// </summary>
        public string MedicineName { get; set; } = string.Empty;
        
        /// <summary>
        /// 数量
        /// </summary>
        public int Quantity { get; set; }
        
        /// <summary>
        /// 单价
        /// </summary>
        public decimal UnitPrice { get; set; }
        
        /// <summary>
        /// 小计金额
        /// </summary>
        public decimal Amount { get; set; }
        
        /// <summary>
        /// 处方ID
        /// </summary>
        public string PrescriptionId { get; set; } = string.Empty;
    }
}